package org.example.day;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/21 23:13
 */
public class Lcp61 {

    public static void main(String[] args) {
        Lcp61 lcp61 = new Lcp61();
        System.out.println(lcp61.temperatureTrend(new int[]{21,18,18,18,31}, new int[]{34,32,16,16,17}));
    }

    public int temperatureTrend(int[] temperatureA, int[] temperatureB) {

        int ans = 0;
        int count = 0;
        for (int i = 0; i < temperatureA.length-1; i++) {
            if(
                    ((temperatureA[i+1] - temperatureA[i]) > 0 && (temperatureB[i+1] - temperatureB[i]) > 0)
                    || ((temperatureA[i+1] - temperatureA[i]) == 0 && (temperatureB[i+1] - temperatureB[i]) == 0)
                    || ((temperatureA[i+1] - temperatureA[i]) < 0 && (temperatureB[i+1] - temperatureB[i]) < 0)
            ){
                count++;
            }else {
                count = 0;
            }
            ans = Math.max(ans, count);
        }

        return ans;

    }

}
